package day7.thread_pool;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
// 功能线程池
public class Demo2 {
    public static void main(String[] args) {
        // 不太建议在实际生产项目下使用
        // 定长线程池
        ExecutorService service = Executors.newFixedThreadPool(10);
        // 单线程化线程池
        ExecutorService service1 = Executors.newSingleThreadExecutor();
        // 可缓存线程池
        ExecutorService service2 = Executors.newCachedThreadPool();
        // 定时线程池
        ExecutorService service3 = Executors.newScheduledThreadPool(10);

        Runnable task = new Runnable() {
            @Override
            public void run() {
                System.out.println("执行任务！");
            }
        };
        service.execute(task);
    }
}
